- user = member.user
- return unless user
- show_roles = true if show_roles.nil?
%li{class: "#{dom_class(member)} js-toggle-container", id: dom_id(member)}
  %span{class: ("list-item-name" if show_controls)}
    = image_tag avatar_icon(user.email, 16), class: "avatar s16"
    %strong= user.name
    %span.cgray= user.username
    - if user == current_user
      %span.label.label-success It's you
    - if user.blocked?
      %label.label.label-danger
        %strong Blocked

  - if show_roles
    %span.pull-right
      %strong= member.human_access
      - if show_controls
        - if can?(current_user, :modify, member)
          = button_tag class: "btn-tiny btn js-toggle-button",
                       title: 'Edit access level', type: 'button' do
            %i.fa.fa-pencil-square-o
        - if can?(current_user, :destroy, member)
          - if current_user == member.user
            = link_to leave_dashboard_group_path(@group), data: { confirm: leave_group_message(@group.name)}, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
              %i.fa.fa-minus.fa-inverse
          - else
            = link_to group_group_member_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
              %i.fa.fa-minus.fa-inverse

    .edit-member.hide.js-toggle-content
      = form_for [@group, member], remote: true do |f|
        .alert.prepend-top-20
          = f.select :access_level, options_for_select(GroupMember.access_level_roles, member.access_level)
          = f.submit 'Save', class: 'btn btn-save btn-small'
